package com.yb.designpattern.creation.singleton;

/**
 * 饿汉式
 * 线程安全的
 * 缺点：即使未用到也会被创建，类加载时就创建，浪费内存 
 * @author Administrator
 *
 */
public class HungrySingleton {
	private static HungrySingleton instance = new HungrySingleton();
	//构造函数的修饰符必须是private的
	private HungrySingleton(){
		
	}
	
	//通过一个静态方法返回单例类的对象
	public static HungrySingleton getInstance(){
		return instance;
	}
}
